#ifndef __SCHED_LOT__
#define __SCHED_LOT__

#include "basesched.h"

using namespace std;

typedef struct task_lottery {
  int pid;
  int tickets;
  bool block;
} task_lottery;

class SchedLottery : public SchedBase {
  public:
    SchedLottery(std::vector<int> argn);
    ~SchedLottery();
    virtual void load(int pid);
    virtual void load(int pid, int deadline);
    virtual void unblock(int pid);
    virtual int tick(int cpu, const enum Motivo m);
    
  private:
    
    
    std::vector< task_lottery > tasksInStandBy;
    int quantum;
    int remainder;
    
    int nextTask(int cpu);
    int choseByDrawLottery(int cpu);
    
    void removeTask(int pid);
    void doCompensation(int pid);    
    void setBlock(int pid, bool block);
    void block(int pid);
};

#endif
